package calorie.com.calorie.adapter;

import android.support.annotation.Nullable;
import android.util.Log;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lxh.baselibray.net.ServiceGenerator;

import java.util.List;

import calorie.com.calorie.R;
import calorie.com.calorie.response.GoodsListResponce;

/**
 * Created by chenxi on 2019/4/10.
 */

public class GoodsListAdapter extends BaseQuickAdapter<GoodsListResponce.DataBean.GoodsListBean,BaseViewHolder> {
    public GoodsListAdapter(int layoutResId, @Nullable List<GoodsListResponce.DataBean.GoodsListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, GoodsListResponce.DataBean.GoodsListBean item) {
        ImageView picView = helper.getView(R.id.goods_pic);//商品图片

        Glide.with(mContext).load(ServiceGenerator.BASE_URL + ":9023/image/"+item.getImgUrl()).into(picView);

        helper.setText(R.id.goods_name,item.getTitle())//商品名称
                .setText(R.id.goods_price,"￥"+item.getPrice()+" CAL");//商品价格
        helper.addOnClickListener(R.id.goods_item);//item点击
    }
}
